package fr.grobim.hangovers.gestionBudget.actions.tableaux.factures;

import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import org.springframework.beans.factory.annotation.Autowired;

import fr.grobim.hangovers.gestionBudget.services.factures.FacturationService;
import fr.grobim.hangovers.gestionBudget.actions.enums.AttributsSession;
import fr.grobim.hangovers.gestionBudget.actions.support.AbstractActionSupportAvecTableau;
import fr.grobim.hangovers.gestionBudget.beans.factures.SourceFacture;

@Namespace(value = "/")
@ResultPath(value = "/")
public class ListerSourceFactureAction extends AbstractActionSupportAvecTableau<SourceFacture> {

	private static final long serialVersionUID = 1L;
	
	@Autowired
	FacturationService facturationService;
	
	@Action(value = "remplirListeSourcesfacture", results={@Result(type = "json")})
	public String remplirTableauSources() {
		List<SourceFacture> sourcesFactureComplete = getObjectDeSession(AttributsSession.GESTION_SOURCE_FACTURE_LISTE);
		
		if (sourcesFactureComplete == null) {
			sourcesFactureComplete = this.facturationService.listerToutesSourcesFacture();
			getSession().put(AttributsSession.GESTION_SOURCE_FACTURE_LISTE.getClee(), sourcesFactureComplete);
		}
		setListeTableau(sourcesFactureComplete);
		return SUCCESS;
	}

	@Override
	public Map<String, Object> getSession() {
		return super.getSession();
	}

	@Override
	public Integer getRows() {
		return super.getRows();
	}

	@Override
	public Integer getPage() {
		return super.getPage();
	}

	@Override
	public String getSord() {
		return super.getSord();
	}

	@Override
	public String getSidx() {
		return super.getSidx();
	}

	@Override
	public String getSearchField() {
		return super.getSearchField();
	}

	@Override
	public String getSearchString() {
		return super.getSearchString();
	}

	@Override
	public String getSearchOper() {
		return super.getSearchOper();
	}

	@Override
	public Integer getTotal() {
		return super.getTotal();
	}

	@Override
	public Integer getRecords() {
		return super.getRecords();
	}

	@Override
	public List<SourceFacture> getListeTableau() {
		return super.getListeTableau();
	}
	
}
